The trick to dealing with these data types is to keep two things in mind:
It's all an illusionC actually has very few data types.
Each data type includes the key to decode its meaning.
Let's take a look at the C data types you will run intosee Table T6-2.
TYPE
BYTES
SIGN
RANGE
char
1
Signed
128 to 127
unsigned char
1
Unsigned
0 to 255
short
2
Signed
32768 to 32767
unsigned short
2
Unsigned
0 to 65535
long
4
Signed
2147483648 to 2147483647
unsigned long
4
Unsigned
0 to 4294967295
int
4
Signed
Same as long under Win32
unsigned int
4
Unsigned
Same as unsigned long under Win32
float
4
Signed
±1.4E-45 to ±3.4E38
double
8
Signed
±4.9E-324 to ±1.7E308
class
*
Varies depending on definition
struct
*
Varies depending on definition
void
0
None
Indicates no type. A function that returns a void is like a VB Subit has no return value.
Table T6-2: C data types
There is also a long double data type and an_intxx type where xx is the size of the integer. These types are rarely usedin fact, I have yet to see them used in any API or DLL function.
You may be wondering, where are the string data types? What about objects and variants? What about Boolean variables?
The trick is in the way the C/C++ language allows you to derive new data types from these native types. Once you derive a new data type, the new type can be used just like those that are built into the language. You'll see how new data types are declared shortly.
1 The C++ language is based on the C language and is essentially identical from the point of view of a Visual Basic programmer. For this reason, C and C++ are used interchangeably in this book. As for declarations being intimidatingthe complex ones can be nearly incomprehensible. In fact, this book was inspired in part by a book called The C Puzzle Book, which consisted largely of complex type declarations the reader had to struggle to understand.